package cmd

import (
	"gitee.com/kristas/booting-go/gen_tool/booctl/logic"
	"gitee.com/kristas/booting-go/gen_tool/booctl/util"
	"github.com/spf13/cobra"
)

var pkgName string

var initCmd = &cobra.Command{
	Use:   "init [name]",
	Short: "Initialize a Booting-go Application",
	Run: func(cmd *cobra.Command, args []string) {
		if pkgName == "" {
			cobra.CheckErr(util.Scan("input go package:", &pkgName))
		}
		if err := logic.InitHandler(pkgName, args); err != nil {
			cobra.CheckErr(err)
		}
	},
}

func init() {
	initCmd.Flags().StringVarP(&pkgName, "pkg", "p", "", "fully qualified package name")
	rootCmd.AddCommand(initCmd)
}
